package cn.com.nes.common.em;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 紧急状态
 *
 * @author lux
 * @date 2018-11-07 16:39
 */
public enum EmergencyDegreeEnum {
    /**
     * 不紧急
     */
    _2("2", "不紧急"),
    /**
     * 一般紧急
     */
    _1("1", "一般紧急"),
    /**
     * 非常紧急
     */
    _0("0", "非常紧急"),

    ;

    private String key;
    private  String val;

    EmergencyDegreeEnum(String key, String val){
        this.key = key;
        this.val = val;
    }

    public String getVal() {
        return val;
    }

    public String getKey(){
        return key;
    }

    public static String getVal(Integer key) {
        if (ObjectUtil.isNull(key)) return StrUtil.EMPTY;
        Map<String, String> map = Arrays.stream(values())
                .collect(Collectors.toMap(EmergencyDegreeEnum::getKey, EmergencyDegreeEnum::getVal));
        return map.get(String.valueOf(key));
    }

}
